window.onload = function () {
	// 捉元素
	star_list = document.getElementById('star_list');
	// 设置定时器
	time = setInterval(run, 3000);

	left = 0;
	//定时器执行的方法
	function run () {

		if(left==-1226){
			paoright = setInterval(runright, 1);
		}else{
			paoleft = setInterval(runleft, 1);
		}
	}

	//跑左
	function runleft(){
		if(left<-1226){
			left=-1226;
			clearInterval(paoleft);
		}else{
			left -=10;
		}
		star_list.style.left = left+"px";
	}
	// 跑右
	function runright(){
		if(left>0){
			left=0;
			clearInterval(paoright);
		}else{
			left +=10;
		}
		star_list.style.left = left+"px";
	}

	cilck_box = document.getElementById('cilck_box');

	//进去停定时器
	cilck_box.onmouseover = function (){
		clearInterval(time);
	}
	//离开开定时器
	cilck_box.onmouseout = function (){
		time = setInterval(run, 3000);
	}

	//点击跑左
	cilck_left.onclick = function (){
		paoleft = setInterval(runleft, 1);
	}
	//点击跑右
	cilck_right.onclick = function (){
		paoright = setInterval(runright, 1);
	}

}